package com.nit.lab.vote.mapper.basic;

import com.nit.lab.vote.dto.basic.TypeDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TypeMapper {
    @Select("<script>select *, type_id As `key` from type " +
            "where true " +
            "<if test = 'typeName != null' >And typeName like concat （'%', #{typeName}, '%'）</if>" +
            "ORDER BY " +
            "<if test='sortField != null'> ${sortField} ${sortOrder}, </if>" +
            "gmt_create desc " +
            "</script>")
    List<TypeDTO> list4Table(
            @Param("typeName")String typeName,
            @Param("start") Integer start,
            @Param("length") Integer length,
            @Param("sortField") String sortField,
            @Param("sortOrder") String sortOrder) throws Exception;

    @Select("<script>select count(*) from type " +
            "where true " +
            "<if test = 'typeName != null'>And typeName like concat （'%', #{typeName}, '%'）</if>" +
            "</script>")
    Long count4Table(
            @Param("typeName") String typeName) throws Exception;
}
